//--------------------------------------------------------------------------------
// This file is a portion of the D2D1Renderer.  It is distributed
// under the MIT License, available in the root of this distribution and 
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Mirco Timmermann
//
//--------------------------------------------------------------------------------
#pragma once

#ifndef _D2_CONTAINER_H
#define _D2_CONTAINER_H

#include "DisplayObject.h"
#include <vector>


namespace D2 {

class DisplayObjectContainer : public DisplayObject {
public:
	DisplayObjectContainer();
	DisplayObjectContainer(int x, int y, int width, int height);
	virtual ~DisplayObjectContainer(void);

	virtual bool Draw(Direct2DContext* direct2DContext, D2D1::Matrix3x2F* mtx = 0);

	virtual DisplayObject* addChild(DisplayObject* displayObject);
	virtual void addChildAt(DisplayObject* displayObject, unsigned int index);
	virtual bool removeChild(DisplayObject* displayObject, bool del = false);
	virtual bool removeChildAt(unsigned int index, bool del = false);
	virtual void removeAllChildren(bool recursive = false, bool del = false);

	virtual DisplayObject* getChildAt(unsigned int index);
	virtual int getNumChildren();

	float GetTotalHeight();
	float GetTotalWidth();

public:
	bool _mouseAvoidingEnabled;
	bool _disableSelfContainerHit;

protected:
	std::vector<DisplayObject*> _children;

protected:
	virtual void _bubbleNotifyAdded(DisplayObject* displayObject);
	virtual void _bubbleNotifyRemoved(DisplayObject* displayObject);

#ifdef _DEBUG
public:
#endif
	virtual DisplayObject* _getObjectsUnderPoint(int mouseX, int mouseY);

public:
	virtual void focus(DisplayObject* displayObject) { }
	virtual void unfocus() { }

/////////
public:
	virtual void toForeground(DisplayObject* displayObject);

};

}

#endif